/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "planilla_pago", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PlanillaPago.findAll", query = "SELECT p FROM PlanillaPago p"),
    @NamedQuery(name = "PlanillaPago.findByIdplanillaPago", query = "SELECT p FROM PlanillaPago p WHERE p.planillaPagoPK.idplanillaPago = :idplanillaPago"),
    @NamedQuery(name = "PlanillaPago.findByFecha", query = "SELECT p FROM PlanillaPago p WHERE p.planillaPagoPK.fecha = :fecha"),
    @NamedQuery(name = "PlanillaPago.findByEstado", query = "SELECT p FROM PlanillaPago p WHERE p.estado = :estado")})
public class PlanillaPago implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PlanillaPagoPK planillaPagoPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "estado", nullable = false)
    private int estado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "planillaPago")
    private Collection<PlanillaPagoDet> planillaPagoDetCollection;
    @JoinColumn(name = "idsucursal", referencedColumnName = "idsucursal", nullable = false)
    @ManyToOne(optional = false)
    private Sucursal idsucursal;

    public PlanillaPago() {
    }

    public PlanillaPago(PlanillaPagoPK planillaPagoPK) {
        this.planillaPagoPK = planillaPagoPK;
    }

    public PlanillaPago(PlanillaPagoPK planillaPagoPK, int estado) {
        this.planillaPagoPK = planillaPagoPK;
        this.estado = estado;
    }

    public PlanillaPago(int idplanillaPago, Date fecha) {
        this.planillaPagoPK = new PlanillaPagoPK(idplanillaPago, fecha);
    }

    public PlanillaPagoPK getPlanillaPagoPK() {
        return planillaPagoPK;
    }

    public void setPlanillaPagoPK(PlanillaPagoPK planillaPagoPK) {
        this.planillaPagoPK = planillaPagoPK;
    }

    public int getEstado() {
        return estado;
    }

    public void setEstado(int estado) {
        this.estado = estado;
    }

    @XmlTransient
    public Collection<PlanillaPagoDet> getPlanillaPagoDetCollection() {
        return planillaPagoDetCollection;
    }

    public void setPlanillaPagoDetCollection(Collection<PlanillaPagoDet> planillaPagoDetCollection) {
        this.planillaPagoDetCollection = planillaPagoDetCollection;
    }

    public Sucursal getIdsucursal() {
        return idsucursal;
    }

    public void setIdsucursal(Sucursal idsucursal) {
        this.idsucursal = idsucursal;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (planillaPagoPK != null ? planillaPagoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PlanillaPago)) {
            return false;
        }
        PlanillaPago other = (PlanillaPago) object;
        if ((this.planillaPagoPK == null && other.planillaPagoPK != null) || (this.planillaPagoPK != null && !this.planillaPagoPK.equals(other.planillaPagoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.PlanillaPago[ planillaPagoPK=" + planillaPagoPK + " ]";
    }
    
}
